package com.fire.convert;

import com.fire.api.dto.MerchantDTO;
import com.fire.entity.Merchant;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.ArrayList;
import java.util.List;


/**
 * 对象类型转换
 */
@Mapper
public interface MerchantConverter {
    //    转换类实例
    MerchantConverter INSTANCE = Mappers.getMapper(MerchantConverter.class);

    //    将dto------entity
    Merchant dto2entity(MerchantDTO merchantDTO);
//    entity----->dto
    MerchantDTO entity2dto(Merchant merchant);
//    list之间也可以转换，将entity的list转化为Dto的list
    List<MerchantDTO> entityList2DtoList(List<Merchant>merchantList);


    public static void main(String[] args) {
        MerchantDTO merchantDTO = new MerchantDTO();
        merchantDTO.setMobile("15095319153");
        Merchant merchant = MerchantConverter.INSTANCE.dto2entity(merchantDTO);

    }
}
